﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TShooter.TfsWord.Resources;
using TShooter.TfsWord.TeamFoundation;

namespace TShooter.TfsWord.Win.UI
{
    public partial class WorkItemPickerDialog : Form
    {
        public WorkItemPickerDialog()
        {
            InitializeComponent();
            InitializeStrings();
        }

        private void InitializeStrings()
        {
            btnOk.Text = Strings.OK;
            btnCancel.Text = Strings.Cancel;
            Text = Strings.SelectWorkItem;
        }

        public DialogResult ShowDialog(Uri teamProjectCollectionName, string projectName)
        {
            InitializePicker(teamProjectCollectionName, projectName);
            return ShowDialog();
        }

        private void InitializePicker(Uri teamProjectCollectionName, string projectName)
        {
            pickWorkItemsControl = WorkItemPickerFactory.CreatePicker(teamProjectCollectionName, projectName);
            pnlPickerContainer.Controls.Add(pickWorkItemsControl);

        }

        public IEnumerable<int> GetSelectedWorkItems()
        {
            return WorkItemPickerFactory.GetSelectedWorkItems(pickWorkItemsControl);
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            //if (SelectedWorkItem != null)
            //{
            Close();
            //}
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}